package com.douqu.game.core.entity.activity;


import com.douqu.game.core.entity.EntityObject;
import com.douqu.game.core.entity.Player;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-03-09 14:27
 */
public class MatchPlayerBase extends EntityObject {


    private String objectIndex;

    private String name;

    private int lv;

    private String avatar;

    private int camp;

    private int winRate;

    /**
     * 最近匹配的记录
     */
    private List<String> matchList;

    public MatchPlayerBase() {
    }

    public MatchPlayerBase(Player player)
    {
        this.objectIndex = player.getObjectIndex();
        this.name = player.getName();
        this.lv = player.getLv();
        this.avatar = player.avatar;
        this.camp = player.camp;
        this.winRate = player.getCampBattleData().getCurWinRate();
        this.matchList = new CopyOnWriteArrayList<>();
//        this.matchList.addAll(player.getCampBattleData().getMatchList());
    }

    public void addMatch(String targetIndex)
    {
        matchList.add(targetIndex);
        if(matchList.size() > 2)
            matchList.remove(0);
    }

    public void update(MatchPlayerBase playerBase)
    {
        this.name = playerBase.name;
        this.lv = playerBase.lv;
        this.avatar = playerBase.avatar;
        this.winRate = playerBase.winRate;
        this.matchList = playerBase.matchList;
    }


    public String getObjectIndex() {
        return objectIndex;
    }

    public void setObjectIndex(String objectIndex) {
        this.objectIndex = objectIndex;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getLv() {
        return lv;
    }

    public void setLv(int lv) {
        this.lv = lv;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }


    public int getCamp() {
        return camp;
    }

    public void setCamp(int camp) {
        this.camp = camp;
    }

    public int getWinRate() {
        return winRate;
    }

    public void setWinRate(int winRate) {
        this.winRate = winRate;
    }

    public List<String> getMatchList() {
        return matchList;
    }

    public void setMatchList(List<String> matchList) {
        this.matchList = matchList;
    }

    @Override
    public String toString() {
        return "{" +
                "objectIndex='" + objectIndex + '\'' +
                ", lv=" + lv +
                ", name='" + name + '\'' +
                ", camp=" + camp +
                ", winRate=" + winRate +
                '}';
    }
}
